#include<iostream>
#include<unistd.h>
#include<fcntl.h>
#include<stdlib.h>

#include<assert.h>
using namespace std;
int main()
{
    int pipefd[2]; //创建匿名管道
    int ret =pipe(pipefd);
    assert(ret ==0);
    pid_t id=fork();

    if(id == 0)
    {
        int cnt =1;
        close(pipefd[0]);
        exit(0); //子进程退出
        while(true)
        {
            char ch;
            read(pipefd[0],&ch,1);
            cout<<"已经读取"<<cnt++<<"字节的数据"<<endl;
        }
        
    }

    //父进程(不写)
    while(true)
    {

    }

    return 0;

}
